<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
use Common\Model\Orders;
use Common\Model\Order_list;
use Common\Model\Shop;
class DingdanController extends Controller{
	public function index(){
		if(isset($_SESSION['uid'])){
		$uid=$_SESSION['uid'];
		$ordersModel=new Orders;
		$data=$ordersModel->where("uid={$uid}")
			->join('order_list','car_orders.oid','=','car_order_list.oid')
			->join('shop','car_order_list.sid','=','car_shop.sid')
			->get();		

//		p($data);		
		View::with('data',$data);
		$Order_listModel=new Order_list;		
		View::make();
		}else{
			View::error('请先登录',U('Member/login'));
		}
	}
//	订单详情
	public function content(){
		$uid=$_SESSION['uid'];
		$olid=Q('get.olid',0,'intval');
		$ordersModel=new Orders;
		$data=$ordersModel->where("uid={$uid}")
			->join('order_list','car_orders.oid','=','car_order_list.oid')
			->join('shop','car_order_list.sid','=','car_shop.sid')
			->where("olid={$olid}")
			->find();
//		p($data);
		View::with('data',$data);
		View::make();
	}
//	支付
	public function pay(){
		if(isset($_SESSION['uid'])){
		$data=$_SESSION['cart']['goods'];		
		View::with('data',$data);
		View::make();
		}else{
			View::error('请先登录',U('Member/login'));
		}	
	
		View::make();
	}
//	添加订单
	public function add(){
		if(IS_AJAX){
//			p($_SESSION);
			$ordersModel = new Orders();
			if(!$ordersModel->store()){
                $this->ajax(['status'=>false,'message'=>$ordersModel->getError()]);
            }else{
                $this->ajax(['status'=>true,'message'=>'提交成功']);
            }
		}
	}
}
